<?php

class home extends Controller
{

	function __constructor()
	{
		parent::__constructor();
		
	}
	function index()
	{
		is_logged_in();
		$this->load->model("model_job");
		$this->load->model("model_user");
		
		
		
		
		
	
		
		$data['jobs_recent'] = $this->model_job->getJobs(10, array("job.created", "desc"), array("job.active" => 1));
		$data['jobs_completed'] =  $this->model_job->getJobs(10, array("job.job_end", "desc"), array("job_end !=" =>  "0000-00-00 00:00:00", "job.active" => 1));
		$data['user_act'] = $this->model_user->getUsers(10, $order = array("user.lastlogin", "desc"), array("user.active" => 1));
		$data['client_act'] = $this->model_user->getUsers(10, $order = array("user.lastlogin", "desc"), array("user.active" => 1, "user.user_type" => 3));
		
		//job hours logged chart
		$r = $data['jobs_completed'];
		$chart_job_x = array();
		$chart_job_y = array();
		
		if(!empty($r))
		{
			foreach($r as $v)
			{
				$chart_job_x[] = $v['company_name'] . " #".$v['id'];
				$chart_job_y[] = ( strtotime($v['job_end']) - strtotime($v['job_start']))/60/60;
			}
		
		$job_hr_logged_chart = Hbar_graph($chart_job_x, $chart_job_y,"job_r","");
		
		//dump($chart_job_x);
		//dump($chart_job_y);die;
		
		$data['charts'][] = ($job_hr_logged_chart );
		}
		
		$this->load->view("home/home",$data);	
	}
	
	
	
}